<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  
<!DOCTYPE html>
<html>
<head>

  <base href="${path}/pages/">
  <meta charset="utf-8">
  <title>${review.title}(${review.movie.movieName})影评</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../layui/css/layui.css"  media="all">
  
  <style type="text/css">
  	a:link {
    	color: #37a;
    	text-decoration: none;
	}
	a:visited {
    	color: #669;
    	text-decoration: none;
	}
	h1{
		font-weight: bold;
    	color: #494949;
    	margin: 0;
    	padding: 0 0 15px 0;
    	line-height: 1.1;
    	font-size: 26px;
	}
  </style>
  
</head>
<body>

<ul class="layui-nav" lay-filter="">
  <li class="layui-nav-item"><a href="${path}/action/user/index"><i class="layui-icon">&#xe68e;</i></a></li>
  <li class="layui-nav-item"><a href="${path}/action/user/index"><i class="layui-icon layui-icon-fire"></i> 影评天下</a></li>
  <li class="layui-nav-item" style="float:right" >
  	<a href="${path}/pages/register.jsp" id="register">注册</a>
  </li>
  <li class="layui-nav-item" style="float:right" >
    <a href="${path}/pages/login.jsp" id="login">登录</a>
  </li>
  <li class="layui-nav-item" style="float:right" >
  <a href="${path}/action/user/userCenter" id="user_center"></a>
  <dl class="layui-nav-child"> <!-- 二级菜单 -->
      <dd><a href="${path}/action/user/logout">登出</a></dd>
   </dl>
  </li>
  <li> <input type="hidden" value="${user.flag }" id="flag"></li>
</ul>


<hr class="layui-bg-gray">
<div class="layui-container">
	<div class="layui-row1">
    	<h1><span>${review.title}</span></h1>
    </div>	
	<div class="layui-row1">
    	<div style="float:left ;margin-left:10px;">
    		<a  href="${path}/action/user/writerInfo?id=${review.writer.id}" title="">
        		${review.writer.userName}
   			</a>
   			评论
   			<a  href="${path}/action/movie/movieInfo?id=${review.movie.id}" title="">
        		${review.movie.movieName}
   			</a>
    	</div>
   		<div style="float:left ;margin-left:16px">
				<c:forEach begin="1" end="${review.rating}"> 
					<img src="../img/star_onmouseover@2x.png" width="16" height="16">
				</c:forEach>
				<c:forEach begin="${review.rating}" end="4"> 
					<img src="../img/star_hollow_hover@2x .png" width="16" height="16">
				</c:forEach>  
   		</div>
   		<div style="float:left ;margin-left:16px;text-align:center;font-size:14px ;height:19px">
				 <p style="margin-top:1px;">${review.createTime}</p>
   		</div>
    </div>
    <div style="margin-top:50px ;font-size:20px;"> <pre>${review.content}</pre></div>
    <div class="layui-row1" style="margin:0 auto;width:15%">
    	<div style="width:30px;float :left" id="add2">
    		<a id="add">
	    	<i class="layui-icon layui-icon-praise" style="font-size: 30px;"></i>
	    	<p style="text-align:center" id="thumb_up">${review.thumb_upAmount}</p>
	    	</a>
    	</div>
    	<a id="write_review">
    	<div style="float :left ;margin-left:15px" class="layui-btn layui-btn-radius layui-btn-normal" >
    		我也要写影评
    	</div>
    	</a>
    </div>
    
</div>
<script type="text/javascript" src="../layui/layui.js"></script>
<script>
layui.use(['element','jquery','layer'],function(){
	var element=layui.element;
	var $=layui.$;
	var layer=layui.layer;
	
	var thumb1=${review.thumb_upAmount};
	var thumb=${review.thumb_upAmount};
	var flag=$('#flag').val();
  	var success=(flag=="");
  	
  	if(success!=true){
          	 $("#user_center").html("个人中心");
          	 $("#login").html("");
          	 $("#register").html("");

      	}else{
      		$("#user_center").html("");
      	 	$("#login").html("登录");
      	 	$("#register").html("注册");
      	}
	
	$("#add").click(function(){
		thumb=thumb+1;
		if(thumb>thumb1+1){
			debugger
		}else{
			
			$.getJSON('${path}/action/review/addThumb_upAmount', {id:"${review.id}"}, function(data) {
				
			    $("#thumb_up").html(data.code);
		     });
		}
	});
	
		
		$("#write_review").click(function(){
			
			if(success==true){
				layer.open({
			  		type: 1,  //打开一个iframe
			  		title: '提示',
			  		anim: 6,
			  		content:"<div style='margin-top:20px; text-align:center' >请先进行登录</div>",
			  		maxmin: true,
			  		area: ['300px', '150px'],
			  		shade: 0,
			  		id:1,
			  		btn: ['确定', '取消'],
			  		yes: function(index, layero){
			  			window.location.href="${path}/pages/login.jsp";
		      		}
				}); 
			}else{
				window.location.href="${path}/action/review/reviewForm?movieId=${review.movie.id}";
			}
			
		});
		

		
	
	
	
})   	
</script>

</body>

</html>